//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for CloudWatchLogs
public struct CloudWatchLogsErrorType: AWSErrorType {
    enum Code: String {
        case dataAlreadyAcceptedException = "DataAlreadyAcceptedException"
        case invalidOperationException = "InvalidOperationException"
        case invalidParameterException = "InvalidParameterException"
        case invalidSequenceTokenException = "InvalidSequenceTokenException"
        case limitExceededException = "LimitExceededException"
        case malformedQueryException = "MalformedQueryException"
        case operationAbortedException = "OperationAbortedException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceUnavailableException = "ServiceUnavailableException"
        case unrecognizedClientException = "UnrecognizedClientException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize CloudWatchLogs
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The event was already logged.
    public static var dataAlreadyAcceptedException: Self { .init(.dataAlreadyAcceptedException) }
    /// The operation is not valid on the specified resource.
    public static var invalidOperationException: Self { .init(.invalidOperationException) }
    /// A parameter is specified incorrectly.
    public static var invalidParameterException: Self { .init(.invalidParameterException) }
    /// The sequence token is not valid. You can get the correct sequence token in the expectedSequenceToken field in the InvalidSequenceTokenException message.
    public static var invalidSequenceTokenException: Self { .init(.invalidSequenceTokenException) }
    /// You have reached the maximum number of resources that can be created.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// The query string is not valid. Details about this error are displayed in a QueryCompileError object. For more information, see QueryCompileError. For more information about valid query syntax, see CloudWatch Logs Insights Query Syntax.
    public static var malformedQueryException: Self { .init(.malformedQueryException) }
    /// Multiple requests to update the same resource were in conflict.
    public static var operationAbortedException: Self { .init(.operationAbortedException) }
    /// The specified resource already exists.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// The specified resource does not exist.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The service cannot complete the request.
    public static var serviceUnavailableException: Self { .init(.serviceUnavailableException) }
    /// The most likely cause is an invalid AWS access key ID or secret key.
    public static var unrecognizedClientException: Self { .init(.unrecognizedClientException) }
}

extension CloudWatchLogsErrorType: Equatable {
    public static func == (lhs: CloudWatchLogsErrorType, rhs: CloudWatchLogsErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension CloudWatchLogsErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
